﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace xiaoxiong.KYJControllersLib
{
    public partial class DeviceState : UserControl
    {
        public DeviceState()
        {
            InitializeComponent();


            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.Selectable, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        }


        private int state = 0;

        [Browsable(true)]
        [Category("自定义属性")]
        [Description("指示灯状态：0 停止；1 运行 ；2 故障 ；其他：备用")]
        public int State
        {
            get { return state; }
            set
            {
                state = value;
                switch (state)
                {
                    case 0:
                        this.BackgroundImage = Properties.Resources.Stop;
                        break;
                    case 1:
                        this.BackgroundImage = Properties.Resources.Run;
                        break;
                    case 2:
                        this.BackgroundImage = Properties.Resources.Fault;
                        break;
                    default:
                        this.BackgroundImage = Properties.Resources.Spare;
                        break;
                }
            }
        }

        [Browsable(true)]
        [Category("自定义属性")]
        [Description("绑定变量的名称")]
        public string BindVarName { get; set; }
    }
}
